Component({
  properties: {
    value: {
      type: Number,
      value: 0
    },
    max: {
      type: Number,
      value: 4000
    },
    label: {
      type: String,
      value: '4000步'
    }
  },
  data: {
    displayValue: 0,
    progressBg: ''
  },
  observers: {
    'value,max': function(value, max) {
      this.updateProgress(value, max);
      this.setData({
        displayValue: value // 显示实际步数
      });
    }
  },
  lifetimes: {
    attached() {
      this.updateProgress(this.data.value, this.data.max);
      this.setData({
        displayValue: this.data.value // 显示实际步数
      });
    }
  },
  methods: {
    updateProgress(value, max) {
      const percent = value > max ? 1 : Math.min(value / max, 1); // 超过max时进度满
      const deg = percent * 360;
      // 进度色为深红色，底色为浅粉色，起点在最上面，顺时针增加
      const progressBg = `conic-gradient(#8B0000 0deg, #8B0000 ${deg}deg, #FFE4E1 ${deg}deg 360deg)`;
      this.setData({ progressBg });
    }
  }
}); 